﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RentHouse.DTO;
using RentHouse.IService;

namespace RentHouse.Web.Controllers
{
    public class HomeController : Controller
    {
        private readonly IHouseService _houseService;
        private readonly ICityService _cityService;
        public HomeController(IHouseService houseService,ICityService cityService)
        {
            this._houseService = houseService;
            this._cityService = cityService;
        }
        public ActionResult Index()
        {   
            ViewBag.CityList = _cityService.GetCity();
            int cityid = 1;
            ViewBag.DefaultCity = _cityService.GetCity().Where(e => e.Id == cityid).FirstOrDefault().Name;
            //读取webconfig中图片路径
            ViewBag.ServerIP = Common.CommonHelper.GetServerIP();
   
            return View();
        }

        public ActionResult LoadMore(int pageIndex,int cityId)
        {
            int pageSize = 6;
            return Json(_houseService.GetList(pageIndex,cityId,pageSize));
        }


    }
}